/*============================================================================
  File:      DmhLocalization.cpp
 
  Summary:   Localization function implementation

  Date:		 June 30, 2004
------------------------------------------------------------------------------
  This file is part of the Microsoft SQL Server Code Samples.
 
  Copyright (C) 2003 Microsoft Corporation.  All rights reserved.
 
This source code is intended only as a supplement to Microsoft
Development Tools and/or on-line documentation.  See these other
materials for detailed information regarding Microsoft code samples.
 
THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.
============================================================================*/

#include "stdafx.h"
#include <atlbase.h>
#include <atlcom.h>
#include <math.h> // Used for log10 - you can omit this
#include "DmhLocalization.h"
#include <stdio.h>


// Implementation of localization

HRESULT		LoadStringFromID(int	iIDString,  // Resource ID of the string
							 LCID	lcid,		// Locale
							 WCHAR	wchar[],	// Buffer into which string is written
							 INT	ccharMax)	// 1 + size of the buffer
{
	// Look up the string and copy into wchar.

	// Default implementation to change: copy the id into the string

	if (ccharMax > log10((double)iIDString) + 3)
	{
		swprintf(wchar, L"ID:%d", iIDString);
	}
	else if (iIDString == -1 && ccharMax >= 30)
	{
		swprintf(wchar, L"Undefined Localized String");
	}

	return S_OK;
}